package com.lyl.syt.controller;

import com.lyl.syt.common.result.Result;
import com.lyl.syt.model.hosp.Hospital;
import com.lyl.syt.modules.mongodb.service.HospitalService;
import com.lyl.syt.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/admin/hosp/hospital")
@RequiredArgsConstructor
public class HospitalController {
    private final HospitalService hospitalService;

    @ApiOperation("获取医院列表")
    @GetMapping("/list/{page}/{limit}")
    public Result<Page<Hospital>> listHospital(@PathVariable int page,
                                               @PathVariable int limit,
                                               HospitalQueryVo queryVo){
        Page<Hospital> hospitalPage = hospitalService.getHospPage(page,limit,queryVo);
        return Result.ok(hospitalPage);
    }

    @ApiOperation("更新医院的上下状态")
    @GetMapping("/updateHospStatus/{id}/{status}")
    public Result<Boolean> updateHospStatus(@PathVariable String id, @PathVariable Integer status){
        hospitalService.updateStatus(id,status);
        return Result.ok();
    }

    @ApiOperation("医院详情信息")
    @GetMapping("/showHospDetail/{id}")
    public Result<Map<String, Object>> showHospDetail(@PathVariable String id){
        return Result.ok(hospitalService.getById(id));
    }
}
